package mark.tom.friend.roll.test;

import android.app.Application;
import android.support.annotation.NonNull;

import com.squareup.leakcanary.LeakCanary;

import mark.tom.friend.CheckResultNotifier;
import mark.tom.friend.ContentChecker;
import mark.tom.friend.FRoll;
import timber.log.Timber;

public class CustomApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        // init LeakCanary
        if (!LeakCanary.isInAnalyzerProcess(this)) {
            LeakCanary.install(this);
        }
        if (BuildConfig.DEBUG) {
            // init Timber
            Timber.plant(new Timber.DebugTree());
        }
        FRoll.init(this)
                .serverChecker(new ContentChecker() {
                    @Override
                    public boolean check(String packageName, String content) {
                        return true;
                    }
                })
                .extraChecker(new ContentChecker() {
                    @Override
                    public boolean check(String packageName, String content) {
                        return true;
                    }
                })
                .checkResultNotifier(new CheckResultNotifier() {
                    @Override
                    public void notify(@NonNull String msg) {
                        Timber.d(msg);
                    }
                })
                .build();
        // 测试Application启动时是否能获取到数据
        Timber.d(FRoll.get().toString());
    }

}
